More and more websites are utilizing ECMAscript-based scripting languages (e.g., JavaScript or Flash) in connection with the content that they host. For example, JavaScript-based content is ubiquitous, and JavaScripts are run by a JavaScript engine that may be realized by a variety of technologies including interpretation-type engines, HotSpot just-in-time (JIT) compilation (e.g., trace based or function based), and traditional-function-based JIT compilation where native code is generated for the entire body of all the functions that gets executed. The HotSpot JITs can employ two mechanisms: (i) interpret the less frequently executed code, and compile to native the most frequently executed code; (ii) do a lightweight and less optimized compile for less frequently executed code, and a heavy and optimized compile for the most frequently executed code.
Interpretation directly involves running the script over a software layer, called an interpreter, which handles the execution of the Scripts by mapping script operations to native code functions implemented in native processor ISA and that runs on processor hardware. Because pure interpretation is slow, most of the current JavaScript engines (e.g., JSC/Nitro, V8, Tracemonkey, and the 1E9 JavaScript engine) used in browsers are using one form of the JIT technology or the other.
JIT-based engines compile the scripts at runtime to native code, and then the native code is executed on the processor hardware. As a consequence, a browser that uses a JIT-based JavaScript engine compiles and executes each piece of JavaScript code as soon as the code is found while parsing the HTML file. And in general, evaluation of JavaScripts forms a large part of browser's overall page load time. For example, if networking delays are not considered, 30% of the page load time may be due to the evaluation of JavaScripts. For a traditional function based JIT JavaScript engine, one-third of the evaluation time for a JavaScript may be due to compilation and the remainder due to execution of the compiled code.
As a consequence, improved apparatus and methods that reduce the time associated with scripting-language processing are desired.